package com.iss.controller.employee;

import com.google.gson.Gson;
import com.iss.model.Employee;
import com.iss.service.EmployeeService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet(urlPatterns = "/emp/list")
public class EmployeeListController extends HttpServlet {

    EmployeeService service = new EmployeeService();


    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {


        /*
         * 集合
         *   List Set Map
        * */
        List<Employee> list = service.getList();


         request.getSession().setAttribute("list",list);


        Gson gson = new Gson();
        response.getWriter().println(gson.toJson(list));
    }
}
